<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->

<div class="users-pane views-list-table" data-ng-init="initViewUrls()">


    <div class="clearfix">
        <ol class="breadcrumb pull-left">
            <li class="active">{{'common.viewUrls' | translate}}</li>
        </ol>
        <div class="pull-right top-margin-4">
            <div class="tooltip-wrapper"  tooltip="{{(createUrlDisabled)? ('urls.noViewInstances' | translate) : ''}}">
            <link-to ng-disabled="createUrlDisabled" route="views.createViewUrl" class="btn btn-primary createuser-btn"><span class="glyphicon glyphicon-plus"></span> {{'urls.createNewUrl' | translate}}</link-to>
        </div>
        </div>
    </div>
    <hr>
    <table class="table table-striped table-hover">
        <thead>
        <tr class="fix-bottom">

            <th class="fix-bottom col-md-2">
                <span>{{'urls.name' | translate}}</span>
            </th>
            <th class="fix-bottom col-md-3">
                <span>{{'urls.url' | translate}}</span>
            </th>
            <th class="fix-bottom col-md-2">
                <span >{{'urls.view' | translate}}</span>
            </th>
            <th class="fix-bottom col-md-2">
                <span>{{'urls.viewInstance' | translate}}</span>
            </th>
        </tr>

        <tr>

            <th class="fix-top">
                <div class="search-container">
                    <input type="text" class="form-control namefilter" placeholder="{{'common.any' | translate}}" ng-model="urlNameFilter" ng-change="resetPagination()">
                    <button type="button" class="close clearfilter" ng-show="urlNameFilter" ng-click="urlNameFilter=''; resetPagination()"><span class="pull-right" aria-hidden="true">&times;</span><span class="sr-only">{{'common.controls.close' | translate}}</span></button>
                    </div>
            </th>
            <th class="fix-top">
                <div class="search-container">
                    <input type="text" class="form-control namefilter" placeholder="{{'common.any' | translate}}" ng-model="urlSuffixfilter" ng-change="resetPagination()">
                    <button type="button" class="close clearfilter" ng-show="urlSuffixfilter" ng-click="urlSuffixfilter=''; resetPagination()"><span class="pull-right" aria-hidden="true">&times;</span><span class="sr-only">{{'common.controls.close' | translate}}</span></button>
                </div>
            </th>
            <th class="fix-top">
                <select class="form-control typefilter v-small-input"
                        ng-model="instanceTypeFilter"
                        ng-options="item.label for item in typeFilterOptions"
                        ng-change="resetPagination()">
                </select>
            </th>
            <th class="fix-top">
            </th>
        </tr>

        </thead>
        <tbody>
        <tr ng-repeat="url in urls.items">

            <td>
                <a href="#/urls/edit/{{url.ViewUrlInfo.url_name}}">{{url.ViewUrlInfo.url_name}}</a>
            </td>
            <td>
                <a target="_blank" href="{{fromSiteRoot('/#/main/view/' + url.ViewUrlInfo.view_instance_common_name + '/' + url.ViewUrlInfo.url_suffix)}}">/main/view/{{url.ViewUrlInfo.view_instance_common_name}}/{{url.ViewUrlInfo.url_suffix}}
                    &nbsp;<i class="fa fa-external-link" aria-hidden="true"></i></a>

            </td>
            <td>
                <span>{{url.ViewUrlInfo.view_instance_common_name}} {{"{"+url.ViewUrlInfo.view_instance_version+"}"}} </span>
            </td>
            <td>
                <span>{{url.ViewUrlInfo.view_instance_name}}</span>
            </td>

        </tr>
        </tbody>
    </table>
    <div class="alert alert-info col-sm-12" ng-show="!urls.items.length">
        {{'urls.noUrlsToDisplay'| translate}}
    </div>
    <div class="col-sm-12 table-bar">
        <div class="pull-left filtered-info">
            <span>{{'common.filterInfo' | translate: '{showed: tableInfo.showed, total: tableInfo.total, term: urs.urls}'}}</span>
            <span ng-show="isNotEmptyFilter">- <a href ng-click="clearFilters()">{{'common.controls.clearFilters' | translate}}</a></span>
        </div>
        <div class="pull-right left-margin">
            <pagination class="paginator" total-items="totalUrls" max-size="maxVisiblePages" items-per-page="urlsPerPage" ng-model="currentPage" ng-change="pageChanged()"></pagination>
        </div>
        <div class="pull-right">
            <select class="form-control" ng-model="urlsPerPage" ng-change="urlsPerPageChanged()" ng-options="currOption for currOption in [10, 25, 50, 100]"></select>
        </div>
    </div>

</div>
